package com.collectplus.express.parcel;

import android.annotation.SuppressLint;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Gravity;
import android.widget.ImageView;
import android.widget.TextView;

import com.collectplus.express.BaseActivity2;
import com.collectplus.express.R;
import com.collectplus.express.logic.AppTab;
import com.collectplus.express.parcel.fragment.BaseReceiverParcelFragment;
import com.collectplus.express.parcel.fragment.ParcelReceiveNoPayFragment;
import com.collectplus.express.parcel.fragment.ParcelReceiveSignedFragment;
import com.collectplus.express.parcel.fragment.ParcelReceiveWaitFragment;

import droid.frame.view.ViewPagerExt;

/**
 * 收到的包裹
 *
 * @author kaka<br>
 *         2017-1-6下午5:44:07
 */
public class ParcelReceiveActivity extends BaseActivity2 {
    /**
     * 进入界面要选择的页面
     */
    private int selectItem;
    protected BaseReceiverParcelFragment mFragment1, mFragment2, mFragment3;

    @Override
    @SuppressLint("ResourceAsColor")
    protected void onCreate(Bundle savedInstanceState) {
        selectItem = getIntent().getIntExtra("item", 0);
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void findViewById() {
        setContentView(R.layout.parcel_receive_main);
        super.findViewById();
        getAppTitle().setCommonTitle("收到的包裹");
        ((TextView) findViewById(R.id.title_middle_text)).setGravity(Gravity.LEFT);

        findViewById(R.id.app_title_layout).setBackgroundColor(Color.parseColor("#fbfbfb"));
        TextView[] mTags = new TextView[3];
        mTags[0] = (TextView) findViewById(R.id.receive_parcel_tab1);
        mTags[1] = (TextView) findViewById(R.id.receive_parcel_tab2);
        mTags[2] = (TextView) findViewById(R.id.receive_parcel_tab3);

        initFragment();

        ViewPagerExt mViewPager = (ViewPagerExt) findViewById(R.id.viewpager);
        ImageView mImgLine = (ImageView) findViewById(R.id.my_parcel_line_img);
        mViewPager.setFragmentItems(getSupportFragmentManager(), mFragment1, mFragment2, mFragment3);
        mViewPager.setSupportScroll(true);

        AppTab appTab = new AppTab(getContext(), 0);
        appTab.initPosition(mViewPager, mImgLine, mTags);

        mViewPager.setCurrentItem(selectItem, true);
    }

    private void initFragment() {
        mFragment1 = new ParcelReceiveNoPayFragment();
        Bundle bundle1 = new Bundle();
        bundle1.putInt("type", 0);
        mFragment1.setArguments(bundle1);
        Bundle bundle2 = new Bundle();
        bundle2.putInt("type", 1);
        mFragment2 = new ParcelReceiveWaitFragment();
        mFragment2.setArguments(bundle2);
        Bundle bundle3 = new Bundle();
        bundle3.putInt("type", 2);
        mFragment3 = new ParcelReceiveSignedFragment();
        mFragment3.setArguments(bundle3);
    }
}
